1. Technical Field
This invention relates to a method and system for storing data blocks onto sectors of a storage device. More specifically, the method and system can be used for optimizing disk drives for variable block-size applications.
2. Description of the Prior Art
When storing information in a computer, a storage device such as a disk drive will have a plurality of sectors that store blocks of data. Serial Advanced Technology Attachment disk drives (SATA) use a rigid 512 bytes per sector format. However, many applications require a larger block size, for example, 520 bytes or 524 bytes, and to use these applications with SATA disk drives requires an intermediate mapping step in which these larger blocks are “mapped” across a number of the fixed sized 512 byte sectors of the SATA disk drive. The design of the mapping layer is critical to the intended application.
Simple mapping algorithms mean that the larger blocks will start and end at various offsets into a 512-byte sector. This makes the most efficient use of the available capacity of the SATA disk drive, but will lead to a substantial performance penalty during data write operations. For some applications performance is not an important consideration, and so this maximum-capacity mapping is appropriate. For other applications where performance is a priority, there is a different mapping algorithm which is less efficient with respect to the memory capacity of the SATA disk drive.
For example, consider an application which uses 524 byte blocks but wants to store these on a SATA disk drive which has 512 byte sectors. The application requires a method of mapping the 524 byte blocks onto the 512 byte sectors of the drive. There are two known methods of mapping the blocks onto the sectors. The first of these can be considered to be a maximum capacity mapping. If the application needs to maximize the capacity available on the drive, the most obvious mapping method simply maps adjacent blocks directly onto adjacent sectors giving a result which looks like this:
Block A occupies from Sector 01 offset 00 to Sector 02 offset 12
Block B occupies from Sector 02 offset 13 to Sector 03 offset 24
Block C occupies from Sector 03 offset 25 to Sector 04 offset 36
Block D occupies from Sector 04 offset 37 to Sector 05 offset 48
Block E occupies from Sector 05 offset 49 to Sector 06 offset 64
. . .
With this mapping, the application can read any range of blocks by simply using the implied algorithm to find the sector where the required range starts and ends, reading that span of sectors from the disk and then shifting out the unwanted data according to the offsets. However, when the application writes a range of blocks, there is an additional problem. For example, to write Block “C” in the mapping above, the application will be writing sectors 03 and 04 on the disk—but sector 03 also contains data for Block “B” and sector 04 also contains data for Block “D”, so it will be necessary to first read those two sectors, then overlay the new data for Block “C” without changing the data for Blocks “B” and “D”, and then re-write the two sectors to the drive. It is this “read/modify/write” process which causes the performance penalty because it requires the same sectors to be under the read/write heads twice, which implies an extra revolution of the disk drive.
The second known mapping technique is a max performance mapping, disclosed in U.S. Patent Publication No. 2006/0117161 to Venturi. If the application needs to maximize the performance available from the disk drive, the application has to avoid the read/modify/write cycles described above, and an appropriate mapping would simply consume two sectors of the disk for each 524-byte block, as shown below:
Block A occupies from Sector 01 offset 00 to Sector 02 offset 12
Block B occupies from Sector 03 offset 00 to Sector 04 offset 12
Block C occupies from Sector 05 offset 00 to Sector 06 offset 12
Block D occupies from Sector 07 offset 00 to Sector 08 offset 12
Block E occupies from Sector 09 offset 00 to Sector 10 offset 12
. . .
With this mapping, reads and writes of any range of blocks will always start on a sector boundary, and will never include data from any block outside the range. This will mean that the read/modify/write problem of the previous mapping method is avoided, and there is therefore no need to use two rotations of the disk drive every time a write function is used to store data on the storage device. Of course, as a result of starting each block of data at a new sector, every second sector will include a large amount of “unused” data space (after offset 12 in the second sector) so this mapping methodology produces a far less efficient use of the available capacity, with almost 50% of the available storage space being unused.
It is therefore an object of the invention to improve upon the known art.